<?php
namespace app\common\services\book;

use \app\common\services\BaseService;
use \app\models\book\Book;
use \app\models\book\BookStockChangeLog;
class BookService extends BaseService
{
	public static function setStockChangeLog($book_id,$quantity,$note){
		if(!$book_id || !$quantity){
			return false;
		}
		$info=Book::find()->where(['id'=>$book_id])->one();

		$model_stock_change=new BookStockChangeLog();
		$model_stock_change->book_id=$book_id;
		$model_stock_change->book_id=$book_id;
		$model_stock_change->unit=$quantity;
		$model_stock_change->total_stock=$info['stock'].$quantity;
		$model_stock_change->note=$note;
		$model_stock_change->created_time=time();
		$res=$model_stock_change->save(0);
		if(!$res){

			return false;
		}
		
		return true;
	}
}